<?php
define('FPDF_FONTPATH','../fpdf/font/');
require('pagegroup.php');
include ("../../include/config.php");
require_once ("../../include/db.php");



class PDF extends PDF_PageGroup
{
function Footer()
{
	$this->SetY(-20);
	$this->Cell(0, 6, 'Page '.$this->GroupPageNo().'/'.$this->PageGroupAlias(), 0, 0, 'C');
}
}

$pdf = new PDF();
$pdf->SetFont('Arial', '', 12);
$pdf->StartPageGroup();
// Gegevens ophalen.
// Tijdsregistratie eerste kolom
$tijdsql="SELECT * FROM $tbparam WHERE datum='23-10-2009'";
$tijdresult=mysql_query($tijdsql);

while ($rowtijd = mysql_fetch_array($tijdresult)) {
	$start = $rowtijd['Beginuur'];
	$eind = $rowtijd['Einduur'];
	$sessie = $rowtijd['Sessieduur'];
	$klasdirectie = $rowtijd['Klasdirectie'];
	}
$aantaluren= $eind-$start;
$aantgespr = $aantaluren*60/$sessie;
//$tijd=$sessie*60;

//Leerkracht per pagina

$sql="SELECT DISTINCT Leerkrachtnaam,LeerkrachtID,Lokaal FROM $tbvak WHERE Klastitularis='Ja' ORDER BY LeerkrachtID ASC ";
$result=mysql_query($sql);

while ($row = mysql_fetch_array($result)) {
	//$id[$teller] = $row['LeerkrachtID'];
	//$teller ++ ;
	$lknaam = $row['Leerkrachtnaam'];
	$lkid = $row['LeerkrachtID'];
	$lok = $row['Lokaal'];

sleep(1);
	
$pdf->AddPage();
//$pdf->Image( "../images/alicebourg50.png" ,155 ,5,40,40);
$pdf->Write(5, $lknaam);
$pdf->Write(5, " ($lkid) ");
$pdf->Write(5,"\n\n");

$event_time = "$start";
$time_block = "$aantgespr";
$event_length = $sessie; // minutes
$teller2 = 0 ;
for($i = 0, $eTime = strtotime($event_time);
$i < $time_block;
$i++, $eTime = strtotime("+$event_length minutes", $eTime))
{
$new_event_time = date('H:i', $eTime);
// Reservaties weergeven

$sqlres="SELECT * FROM $tbres WHERE LeerkrachtID='$lkid' ";
			$resultres=mysql_query($sqlres);
				
				while ($rowres =mysql_fetch_array($resultres)) {
						$lln = $rowres['Gebruikersnaam'];
						$klas = $rowres['Klas'];
						$uur = $rowres['Uur'];
						$vak = $rowres['Vak'];
						$stijn="0";
if ($uur == $new_event_time) {

$pdf->Cell(30,10,"$new_event_time|$teller2|",1,0);
$pdf->Cell(110,10,"$lln",1,1);
$stijn="1";
}
}
if ($stijn == "0") {
$pdf->Cell(30,10,"$new_event_time|$teller2|",1,0);
$pdf->Cell(110,10,"...........................................................................................",1,1);
}
$teller2++;
}
}
$pdf->Output();

mysql_close();
?>
